<%@ page import="bog.Tag" %>
<div id="create-thread" class="content scaffold-create" role="main">
    <g:set var="entityName" value="${message(code: 'thread.label', default: 'Thread')}"/>
    <h1><g:message code="default.create.label" args="[entityName]"/></h1>
    <g:if test="${flash.message}">
        <div class="message" role="status">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${threadInstance}">
        <div class="alert alert-error">
            <ul class="errors" role="alert">
                <g:eachError bean="${threadInstance}" var="error">
                    <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
                            error="${error}"/></li>
                </g:eachError>
            </ul>
        </div>
    </g:hasErrors>

    <g:form action="save">
        <fieldset class="form">
            <div class="fieldcontain ${hasErrors(bean: threadInstance, field: 'question.title', 'error')} required">
                <label for="title">
                    <g:message code="question.title.label" default="Question" />
                    <span class="required-indicator">*</span>
                </label>
                <g:textField name="title" class="input-block-level" required="required" value="${threadInstance?.question?.title}"/>
            </div>

            <div class="fieldcontain ${hasErrors(bean: threadInstance, field: 'question.content', 'error')} required">
                <label for="content">
                    <g:message code="question.content.label" default="Details" />
                    <span class="required-indicator">*</span>
                </label>

                <g:textArea name="content" class="input-block-level" rows="12" cols="50" required="required" value="${threadInstance?.question?.content}"/>
            </div>

            <div class="fieldcontain ${hasErrors(bean: threadInstance, field: 'course', 'error')} required">
                <label for="course">
                    <g:message code="thread.course.label" default="Course" />
                    <span class="required-indicator">*</span>
                </label>
                <g:select id="course" name="course" from="${bog.Course.list()}" optionKey="id" required="" value="${threadInstance?.course?.id}" class="many-to-one"/>
            </div>

            <div class="fieldcontain ${hasErrors(bean: threadInstance, field: 'tags', 'error')} ">
                <label for="tags">
                    <g:message code="thread.tags.label" default="Tags" />

                </label>
                <g:select name="tags" from="${bog.Tag.list()}" multiple="multiple" optionKey="id" size="5" value="${threadInstance?.tags*.id}" class="many-to-many"/>
            </div>
        </fieldset>

        <br />
        <g:submitButton name="create" class="btn btn-primary" value="${message(code: 'default.button.create.label', default: 'Create thread')}" />
    </g:form>
</div>